package top.maof.book.spider.runtime;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Pair implements Comparable<Pair> {

    private String url;

    private String title;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return Objects.equals(url, pair.url) &&
                Objects.equals(title, pair.title);
    }

    @Override
    public int hashCode() {
        return Objects.hash(url, title);
    }


    @Override
    public int compareTo(Pair o) {
        return url.equals(o.url) ? 0 : -1;
    }
}
